<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>主界面</title>
<script type="text/javascript" src="<%=request.getContextPath() %>/common/jquery-1.8.2.min.js"></script>
<jsp:include page="/common/easyui.jsp"></jsp:include>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/ztree/jquery.ztree.all-3.4.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/common/ztree/jquery.ztree.excheck-3.5.js"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/common/ztree/metroStyle/metroStyle.css" type="text/css"></link>
<script type="text/javascript">
var setting = {
		data : {
			key : {
				children : "children",
				name : "name",
				url : "xUrl"
			},
			simpleData : {
				enable : true,
				idKey : "id",
				pIdKey : "pid",
				rootPId : 0
			}
		},
		callback : {
			onClick : function(event, treeId, treeNode) {
				if (!treeNode.isParent) {
					 openTab(treeNode.xUrl,treeNode.name);
				}
			}
		}
	};
	
	$(function(){
		$.ajax({
				type:"post",
				url:"<%=request.getContextPath()%>/common/tree.json",
				dataType:"json",
				success:function(treeJson){
					zTreeObj = $.fn.zTree.init($("#ztree"), setting, treeJson);
					zTree_Menu = $.fn.zTree.getZTreeObj("ztree");
					curMenu = zTree_Menu.getNodes()[0].children[0].children[0];
					zTree_Menu.selectNode(curMenu);
					var a = $("#" + zTree_Menu.getNodes()[0].tId + "_a");
					a.addClass("cur");
				}
		});
		
		
		
		$('#style').combo({    
		    required:true,    
		    multiple:true   
		});  
		
	});
	
	function openTab(url,name){
		if($("#tabs").tabs("exists",name)){
			$.messager.alert('excuse me','has open'); 
			$("#tabs").tabs("select",name);
		}else{
				var content="<iframe frameborder='0' scrolling='auto' style='width:100%;height:100%' src='<%=request.getContextPath()%>/"+url+"'></iframe>";
				$("#tabs").tabs("add",{
					title:name,
					closable:true,
					content:content
				});
			
		}
	}
	function showmenu(){
		$('#menu').menu('show', {    
		  left: 1120,    
		  top: 30    
		});  
	}
	function menuHandler(item){
		var link = $("#sty");
		var stylename=item.name; 
		if(stylename=="default"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/default/easyui.css');
		}else if(stylename=="metro"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/metro/easyui.css');
		}else if(stylename=="bootstrap"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/bootstrap/easyui.css');
		}else if(stylename=="black"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/black/easyui.css');
		}else if(stylename=="gray"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/gray/easyui.css');
		}else if(stylename=="cupertino"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/ui-cupertino/easyui.css');
		}else if(stylename=="dark"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/ui-dark-hive/easyui.css');
		}else if(stylename=="pepper-grinder"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/ui-pepper-grinder/easyui.css');
		}else if(stylename=="sunny"){
			$("#sty").attr("href",'<%=request.getContextPath() %>/common/easyui/themes/ui-sunny/easyui.css');
		}
	}
	
</script>
<!-- 	<style type="text/css">
.ztree li a.level0 {width:130;height: 20px; text-align: center; display:block; background-color: #222 ; border:1px silver solid;}
.ztree li a.level0.cur {background-color: #66A3D2; }
.ztree li a.level0 span {display: block; color: white; padding-top:3px; font-size:12px; font-weight: bold; word-spacing: 2px;}
.ztree li a.level0 span.button {	float:right; margin-left: 10px; visibility: visible;display:none;}
.ztree li span.button.switch.level0 {display:none;}
	</style> -->
</head>
<body class="easyui-layout">   
    <div data-options="region:'north',split:true" style="height:100px;">
		<div style="float: left;">
	    	<h1>
		    	尊敬的：${sessionScope.user.realname} 你好！
	    	</h1>
	    	<a href="<%=request.getContextPath() %>/user/outLogin.do" class="easyui-linkbutton" data-options="iconCls:'icon-back'">退出登录</a>  
		</div>
		<div style="float: right;">
			<a class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="showmenu()">设置皮肤</a>  
			<div id="menu" class="easyui-menu" data-options="onClick:menuHandler"  style="width:120px;">   
			    <div data-options="name:'default'">默认</div>   
			    <div data-options="name:'metro'">metro</div>
			    <div data-options="name:'bootstrap'">bootstrap</div>
			    <div data-options="name:'gray'">gray</div>
			    <div data-options="name:'cupertino'">cupertino</div>
			    <div data-options="name:'dark'">dark</div>  
				<div data-options="name:'black'">black</div>
				<div data-options="name:'pepper-grinder'">pepper-grinder</div>
				<div data-options="name:'sunny'">sunny</div>
			</div>  
		</div>
    </div>   
    <div data-options="region:'west',split:true" style="width:150px;">
    	<ul id="ztree" class="ztree"></ul>
   	</div>   
    <div data-options="region:'center'" style="padding:5px;background:#eee;">
    	<div id="tabs" class="easyui-tabs" style="width:1150px;height:500px;">  
    		 <div title="欢迎" style="padding:20px;">   
		       	欢迎
		    </div>   
		</div>
    </div>   
</body> 
</html>